package cn.lyjuan.payment.third.base.pay.chl.impl.iap.enums;

import cn.lyjuan.base.util.StringUtils;

/**
 * @author arvin
 * desc payment-third cn.lyjuan.payment.third.base.pay.chl.impl.iap.enums
 * 2021/3/8 14:11
 */
public enum IosDevelopEnum {

    /**
     *
     */
    Sandbox("Sandbox"),
    Prod("Prod"),
    //
    ;
    private String value;

    IosDevelopEnum(String value) {
        this.value = value;
    }

    /**
     * find enum
     *
     * @param value value
     * @return IosDevelopEnum
     */
    public static IosDevelopEnum find(String value) {
        if (value == null) {
            return null;
        }
        for (IosDevelopEnum tmpEnum : values()) {
            if (tmpEnum != null && tmpEnum.getValue().equals(value)) {
                return tmpEnum;
            }
        }
        return null;
    }

    public static IosDevelopEnum parse(String service) {
        if (StringUtils.isNull(service)) {
            throw new RuntimeException("iap devType can not be null");
        }
        if (service.equalsIgnoreCase(Sandbox.value)) {
            return Sandbox;
        }
        if (service.equalsIgnoreCase(Prod.value)) {
            return Prod;
        }
        throw new RuntimeException("ali service unsupported: " + service);
    }

    public String getValue() {
        return value;
    }
}
